local dichao = fk.CreateSkill {
  name = "lvshi__dichao",
  tags = { Skill.Lord }
}

Fk:loadTranslationTable{
  ["lvshi__dichao"] = "涤朝",
  [":lvshi__dichao"] = "主公技，回合开始时，你可令任意名其他群势力角色此回合不计入距离和座次；回合结束时，若你此回合至少造成X点伤害，你摸X张牌（X为群势力角色数）。",
  ["#ls__dichao-choose"] = "涤朝：请选择任意名群势力角色",

  ["$lvshi__dichao1"] = "满朝诸公，视吾剑不利否？",
  ["$lvshi__dichao2"] = "顺我者生，逆我者十死无生。",
}

dichao:addEffect(fk.TurnStart,{
  anim_type = "special",
  on_cost = function(self, event, target, player, data)
    local targets = table.filter(player.room:getOtherPlayers(player), function (p) return p.kingdom == "qun" end)
      local to = player.room:askToChoosePlayers(player, {
        min_num = 1,
        max_num = #targets,
        targets = targets,
        skill_name = dichao.name,
        prompt = "#ls__dichao-choose",
        cancelable = true,
      })
      if #to > 0 then
        event:setCostData(self, {tos = to})
        return true
      end
  end,
  on_use = function(self, event, target, player, data)
    for _, p in ipairs(event:getCostData(self).tos) do
      player.room:addPlayerMark(p, "PlayerRemoved-turn")
    end
  end,
})

dichao:addEffect(fk.TurnEnd,{
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(dichao.name) and target == player then
      local num = #table.filter(player.room:getAlivePlayers(), function (p) return p.kingdom == "qun" end)
      local n = 0
      player.room.logic:getActualDamageEvents(999, function (e)
        if (e.data.from and e.data.from == player) then
          n = n + e.data.damage
        end
      end, Player.HistoryTurn)
      return n >= num
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    local num = #table.filter(player.room:getAlivePlayers(), function (p) return p.kingdom == "qun" end)
    player:drawCards(num, dichao.name)
  end,
})


return dichao